Requiered Libraries

library(tidyverse)
#install.packages ("seacarb")
#Gibbs Seawater
library(seacarb)
library(gsw)
library(ggplot2)

Import the data

hydrostation_bottle <- read_delim("hydrostation_bottle.txt", 
    delim = "\t", escape_double = FALSE, 
    col_names = FALSE, trim_ws = TRUE, skip = 31)
hydrostation_bottle_names <- read_csv("hydrostation_bottle.txt", 
    skip = 30)
#Fix names for the dataset
colnames(hydrostation_bottle) = colnames(hydrostation_bottle_names)
view(hydrostation_bottle)

Variables Names and Units

Quality flags

hydrostation_bottle %>% 
  filter(`Sig-th` != -999 & Depth < 20) %>% 
  ggplot()+
  geom_point(aes(x = decy, y = `Sig-th`))+
  geom_line(aes(x =decy, y = `Sig-th` ))

#Clear Seasonal signal for sigma-theta
hydrostation_bottle %>% 
  filter(`Sig-th` != -999 & Depth < 20) %>% 
  ggplot()+
  geom_point(aes(x =Temp, y = `Sig-th` ))

#Density and Temperature are strongly correlated, but there appears to be two outliners that we will likely need to address at some point
#We only have density data from 1988-present, but temperature and salinity data from 1950s-present, this mean i can calculate seawater density from 1950s- present, by using TEOS-10. 

TEOS-10 Toolbox in package seacarb

#Has surface sigma theta decreased over time?

HydroS_Shallow = HydroS_corrected %>% 
  filter(Depth<30)
?lm
## starting httpd help server ... done
#lm(y is a function(~) of x)
lm(sig_theta_gsw~decy,data = HydroS_Shallow)
## 
## Call:
## lm(formula = sig_theta_gsw ~ decy, data = HydroS_Shallow)
## 
## Coefficients:
## (Intercept)         decy  
##    56.28396     -0.01563
#y = mx+b
#Coeficients: intercept = b, decy = m 
#Sig_theta_gws = -0.01563*decy + 56.28
#(kg/m^3) = (kg/m^3/x)*x + (kg/m^3)
sig_theta_model = lm(sig_theta_gsw~decy,data = HydroS_Shallow)
summary(sig_theta_model)
## 
## Call:
## lm(formula = sig_theta_gsw ~ decy, data = HydroS_Shallow)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.6372 -0.8673  0.1377  0.8460  1.6206 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 56.28396    4.39141  12.817  < 2e-16 ***
## decy        -0.01563    0.00219  -7.139 1.31e-12 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.9219 on 2001 degrees of freedom
## Multiple R-squared:  0.02483,    Adjusted R-squared:  0.02435 
## F-statistic: 50.96 on 1 and 2001 DF,  p-value: 1.313e-12
library(plotly)
## 
## Attaching package: 'plotly'
## 
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## 
## The following object is masked from 'package:stats':
## 
##     filter
## 
## The following object is masked from 'package:graphics':
## 
##     layout
Sig_decy_plot = HydroS_Shallow %>% 
  ggplot(aes(x = decy, y = sig_theta_gsw))+
  geom_point()+
  geom_line()+
  geom_smooth(method = "lm")+
  theme_classic()
ggplotly(Sig_decy_plot)
## `geom_smooth()` using formula 'y ~ x'

Lab Assigment

  1. Pick a question (Include hypothesis) Is density influenced more by temperature or salinity in the surface layer? Do salinity and temperature co-vary?

Hypothesis: Temperature have a greater effect on density in the surface layer.

  1. produce a plot and a statistical summary
Densityplot=
 HydroS_corrected%>%
  filter(Depth<150) %>% 
  ggplot()+
  geom_point(aes(x=Depth,y= sig_theta_gsw))+
  xlab('Depth (m)')+
  ylab('Sig-theta (kg/m^3)')+
  scale_y_reverse()+
  scale_x_continuous(position ="bottom")

Densityplot

Densityplot=
 HydroS_corrected%>%
  filter(Depth<150) %>% 
  ggplot()+
  geom_point(aes(x=Depth,y= sig_theta_gsw))+
  xlab('Depth (m)')+
  ylab('Sig-theta (kg/m^3)')+
  scale_y_reverse()+
  scale_x_continuous(position ="bottom")
  1. Describe your results, the summary, and answer the question

  2. Compile into a completed lab report using R Markdown

Potential questions: how do temp, sal, and sigma-theta co-vary Is there a relationship between sigma-theta and oxygen? Is there a relationship of any of the parameter with depth? with time? within depth over time? Are there seasonal differences in any of the parameters?